<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" type="text/css" href="../css/aui.css" />
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>登陆</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
    	.aui-bar-nav{
    		background-color: #f5f5f5;
    	}
    	.aui-bar .aui-iconfont {
			/*color: #03a9f4;*/
			position: relative;
			z-index: 20;
			font-size: 0.9rem;
			font-weight: 400;
			line-height: 2.25rem;
		}
    	.aui-bar .aui-btn {
			position: relative;
			z-index: 20;
			height: 2.25rem;
			line-height: 2.25rem;
			padding-top: 0;
			padding-bottom: 0;
			margin: 0;
			border-radius: 0.1rem;
			border-width: 0;
			background: transparent !important;
		}

		 .forget{ margin-top: 20px; }
    	h1 { font-weight:400; height: 120px; line-height: 120px; text-align: center;}
    </style>
</head>
<body>

	<h1>邦建云办公LOGIN</h1>
	<div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-form-list">
					<li class="aui-list-item">
							<div class="aui-list-item-inner">
									<div class="aui-list-item-label-icon">
											<i class="aui-iconfont aui-icon-info"></i>
									</div>
									<div class="aui-list-item-input">
											<input type="number" id="ip_id" placeholder="请输入服务器IP地址">
									</div>
							</div>
					</li>
						<li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label-icon">
                        <i class="aui-iconfont aui-icon-mobile"></i>
                    </div>
                    <div class="aui-list-item-input">
                        <input type="text" id="user_id" placeholder="请输入账号">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label-icon">
                        <i class="aui-iconfont aui-icon-lock"></i>
                    </div>
                    <div class="aui-list-item-input">
                        <input type="password" id="pwd_id" placeholder="请输入密码">
                    </div>
                    <!--<div class="aui-list-item-label-icon">
                        <i class="aui-iconfont aui-icon-display"></i>
                    </div>-->
                </div>
            </li>
        </ul>
    </div>
    <div class="aui-content aui-margin-r-15 aui-margin-l-15">
    	<div class="aui-btn aui-btn-info aui-btn-block aui-btn-sm" onclick="login()">登 陆</div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/aui-toast.js" ></script>
<script type="text/javascript">
var toast = new auiToast();

	apiready = function(){
            api.addEventListener({
              name: 'keyback'
          }, function(ret, err) {
              return false;
          });

	};

	function login (){
		//获取用户输入的
		var user = $api.val($api.byId('user_id'));
		var pwd = $api.val($api.byId('pwd_id'));
		//用户点击登陆就加载
		api.showProgress({
		    style: 'default',
		    animationType: 'fade',
		    title: '拼命登陆中...',
		    text: '不如喝茶去...',
		    modal: false
		});
		api.ajax({
		    url: ServeUrl+'m=Index&a=login',
		    method: 'post',
		    data: {
		        values: {
		            username:user,
		            password:pwd
		        }
		    }
		},function(ret, err){
				api.hideProgress();
				if (ret.data.status == 1) {
            //储存id
            $api.setStorage('cn_name',ret.data.cn_name);
            $api.setStorage('username',ret.data.username);
                        $api.setStorage('phone',ret.data.phone);
						$api.setStorage('user_img',ret.data.user_img);
            //doScript();
		    		//先获取id
		        /*api.alert({
		           title:'登陆成功',
		         	 msg:'恭喜你，登陆成功了哦',
	          },function(ret){
	             	if(ret.buttonIndex == 1){
										//api.closeWin();
										api.closeToWin({
										    name: 'root',
												reloa:true,
										});
	             	}
	          });*/
						toast.success({
								title:"已加载所有日报",
								duration:2000
						});
						api.closeToWin({
								name: 'root',
								reloa:true,
						});
						api.sendEvent({
								name:'loginSuccess'
						});
		    } else if(ret.data.status == 2) {
						//储存id
						$api.setStorage('cn_name',ret.data.cn_name);
            $api.setStorage('username',ret.data.username);
						//doScript();
						//先获取id
					  api.alert({
								title:'登陆成功',
								msg:'未绑定手机号，请绑定',
						},function(ret){
								if(ret.buttonIndex == 1){
										api.openWin({
						            name: "bind_phone",
						            url: 'bind_phone_win.html',
						        });
								}
						});
						api.sendEvent({
								name:'loginSuccess'
						});
				} else {
		        api.toast({
              msg:ret.data.msg
            });
		    }
		});
	}



	function closeWin(){
		api.closeWin();
	}

	
</script>
</html>
